package api

import (
	"jgt-oper/src/bll"
	"jgt-oper/src/context"
	"jgt-oper/src/schema"
)

// Park 园区管理
type Park struct {
	ParkBll *bll.Park `inject:""`
}

// QueryList 查询园区列表数据
func (a *Park) QueryList(ctx *context.Context) error {
	name := ctx.Query("name")

	parent, err := a.ParkBll.GetByNameAndType(name, 10)

	params := schema.ParkSelectParam{
		ParentID: parent.RecordID,
		Type:     20,
	}

	items, err := a.ParkBll.QueryList(params)
	if err != nil {
		return ctx.ResErrInternalServer(err)
	}
	return ctx.ResSuccess(items)
}
